<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${basePkg}.${beanName}.mapper.${BeanName}Mapper">


    <select id="query" parameterType="ActionValues" resultType="ResultValues" >
        select * from ${tableName}
        where 1=1
        <#list fields as fd>
		<if test="${fd.name}!=null">and ${fd.cname}=<#noparse>#{</#noparse>${fd.name}<#noparse>}</#noparse></if>
		</#list>
        order by create_time desc
    </select>
   
    <insert id="add${BeanName}" parameterType="${basePkg}.${beanName}.entity.${BeanName}">
        insert into ${tableName}(
        <#list fields as fd>
		      <if test="${fd.name}!=null"><#if (fd_index > 0)>,</#if>${fd.cname}</if>
	    </#list>
		      )values(
			  <#list fields as fd>
			        <if test="${fd.name}!=null"><#if (fd_index > 0)>,</#if><#noparse>#{</#noparse>${fd.name}<#noparse>}</#noparse></if>
              </#list>
		)
	</insert>

    <update id="update${BeanName}" parameterType="${basePkg}.${beanName}.entity.${BeanName}">
        update ${tableName}	 
		<trim prefix="set " prefixOverrides=",">
        <#list fields as fd>
		<#if fd.primary><#else>
          <if test="${fd.name}!=null">,${fd.cname}=<#noparse>#{</#noparse>${fd.name}<#noparse>}</#noparse></if>
		</#if>
		</#list>
		</trim>
		where ${priKeyColumn}=<#noparse>#{</#noparse>${priKey}<#noparse>}</#noparse>
	</update>
</mapper>